﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;

namespace YTSK.Report
{
    public class ReportToolBar:ReportData
    {
        public ToolStrip _toolstrip;

        #region 初始化

        public ReportToolBar(Control main, DataGridView dg, string ReportCode, ToolStrip toolstrip) :
            base(main, dg, ReportCode)
        { _toolstrip = toolstrip; }
        #endregion

        #region  增加ToolBar的事件
        public override void InitControl()
        {
            base.InitControl();
            foreach (ToolStripItem bar in _toolstrip.Items)
            {
                if (bar.Text.Length > 0)
                { bar.Click += toolbar_click; }
            }
        }
        #endregion 增加ToolBar的事件

        #region 工具栏事件
        public virtual void toolbar_click(object sender, EventArgs e)
        {
            if (sender.GetType() != typeof(ToolStripButton)) { return; }
            var bt = (ToolStripButton)sender;
            var text = bt.Text;
            switch (text)
            {
                case "导出":
                    Common.handleDataGrid.ExportExcel(base._dg);
                    break;
                case "退出":
                    var parent = (Form)_main.Parent;
                    parent.Close();
                    break;
            }
        }
        #endregion
    }
}
